<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/commons/inc.jsp" %>
<script type="text/javascript" src="${contextPath}/js/ajax.js"></script>

<h3 id="navTitleId">营养随访</h3>

<body id="body">

<%@include file="/commons/showmessage.jsp" %>

<form name="nutriSuifangform" id="nutriSuifangform" method="post" action="${contextPath}/nutrition/nutrition.action?method=saveEditNutritionSuifang">
	<s:hidden name="nutriSuifang.seqid" id="nutriSuifang.seqid"></s:hidden>
	<s:hidden name="nutriSuifang.patientid" id="nutriSuifang.patientid"></s:hidden>
	<s:hidden name="patientid" id="patientid"></s:hidden>
	
	<table>
		<tr> 
			<td class="tdLabel" colspan="7"><label class="label">是否按推荐饮食:</label>
				<select name="nutriSuifang.recommend" id="nutriSuifang.recommend" onchange="changeSel(this, ${patientid})">
					<option value="0" <s:if test="nutriSuifang.recommend == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="nutriSuifang.recommend == 1">selected</s:if>>是</option>
					<option value="2" <s:if test="nutriSuifang.recommend == 2">selected</s:if>>否</option>
				</select></td>
		</tr>
	</table>
	<table border="0" cellspacing="1" cellpadding="0" class="formTable" width="100%" >
      <thead>
        <tr>
          <td width="20" align="center" class="form-th">食用量(g)</td>
          <td width="20"  align="center" class="form-th">谷薯类(主食)</td>
		  <td width="20" align="center" class="form-th">蔬菜类</td>
          <td width="20"  align="center" class="form-th">鱼肉蛋类</td>
          <td width="20" align="center" class="form-th">豆类</td>
          <td width="20"  align="center" class="form-th">乳类</td>
          <td width="20"  align="center" class="form-th">水果类</td>
          <td width="20"  align="center" class="form-th">油脂类</td>
        </tr>
      </thead>
      <tbody>
      <tr>
         <td align="left" class="form-td">早餐</td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.zhushia" size="5" id="nutriSuifang.zhushia" value="${nutriSuifang.zhushia}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.shucaia"  size="5" id="nutriSuifang.shucaia" value="${nutriSuifang.shucaia}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.yuroua"  size="5" id="nutriSuifang.yuroua" value="${nutriSuifang.yuroua}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.doua"  size="5" id="nutriSuifang.doua" value="${nutriSuifang.doua}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.rua"  size="5" id="nutriSuifang.rua" value="${nutriSuifang.rua}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.shuiguoa" size="5" id="nutriSuifang.shuiguoa" value="${nutriSuifang.shuiguoa}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.youzhia"  size="5" id="nutriSuifang.youzhia" value="${nutriSuifang.youzhia}"/></td>
      </tr>  
     <tr>
         <td align="left" class="form-td">中餐</td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.zhushib"  size="5" id="nutriSuifang.zhushib" value="${nutriSuifang.zhushib}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.shucaib"  size="5" id="nutriSuifang.shucaib" value="${nutriSuifang.shucaib}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.yuroub"  size="5" id="nutriSuifang.yuroub" value="${nutriSuifang.yuroub}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.doub"  size="5" id="nutriSuifang.doub" value="${nutriSuifang.doub}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.rub"  size="5" id="nutriSuifang.rub" value="${nutriSuifang.rub}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.shuiguob" size="5" id="nutriSuifang.shuiguob" value="${nutriSuifang.shuiguob}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.youzhib" size="5" id="nutriSuifang.youzhib" value="${nutriSuifang.youzhib}"/></td>
      </tr>
      <tr>
         <td align="left" class="form-td">晚餐</td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.zhushic" size="5" id="nutriSuifang.zhushic" value="${nutriSuifang.zhushic}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.shucaic"  size="5" id="nutriSuifang.shucaic" value="${nutriSuifang.shucaic}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.yurouc"  size="5" id="nutriSuifang.yurouc" value="${nutriSuifang.yurouc}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.douc"  size="5" id="nutriSuifang.douc" value="${nutriSuifang.douc}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.ruc" size="5" id="nutriSuifang.ruc" value="${nutriSuifang.ruc}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.shuiguoc" size="5" id="nutriSuifang.shuiguoc" value="${nutriSuifang.shuiguoc}"/></td>
         <td align="left" class="form-td"><input type="text" name="nutriSuifang.youzhic"  size="5" id="nutriSuifang.youzhic" value="${nutriSuifang.youzhic}"/></td>
      </tr>
       <tr>
         <td align="left" class="form-td">合计</td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.zhushitotal" size="5" id="nutriSuifang.zhushitotal" value="${nutriSuifang.zhushitotal}"/></td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.shucaitotal" size="5" id="nutriSuifang.shucaitotal" value="${nutriSuifang.shucaitotal}"/></td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.yuroutotal" size="5" id="nutriSuifang.yuroutotal" value="${nutriSuifang.yuroutotal}"/></td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.doutotal" size="5" id="nutriSuifang.doutotal" value="${nutriSuifang.doutotal}"/></td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.rutotal" size="5" id="nutriSuifang.rutotal" value="${nutriSuifang.rutotal}"/></td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.shuiguototal" size="5" id="nutriSuifang.shuiguototal" value="${nutriSuifang.shuiguototal}"/></td>
         <td align="left" class="form-td"><input type="text"  name="nutriSuifang.youzhitotal" size="5" id="nutriSuifang.youzhitotal" value="${nutriSuifang.youzhitotal}"/></td>
      </tr>
      </tbody>
    </table>
 	 
	<table>
		<tr>
			<td align="center"> 
			<input type="reset" value="重置">  
		    <input type="button" onclick="saveEdit('save');" value="保存">
		    <input type="button" onclick="setEmpty();" value="置空"></td>
		</tr>
	</table>
</form>

<%@include file="/commons/tableSel.jsp" %>

</body>

<style type="text/css">
body {
	height: 100%;
	width: 100%;
}
</style>

<script>
function saveEdit(type){
	if(type=='refresh'){
		location.reload();
	}else if(type=='save'){
		if(!Validator.Validate($('nutriSuifangform'),3)){
			return;
		}	
		$('nutriSuifangform').submit();
	}
}
function changeSel(obj,patientid){
	var ajax = new postAjax();
	var url,value;
	var sel = obj.options[obj.selectedIndex].value;
	
	url = "nutrition/nutrition.action?method=getNutritionRecomInfo&";
	value = "patientid=" + patientid;
	if(sel==1){
		ajax.connect(url,value,recomCallback);
	}else if(sel==2){
		setEmpty();
	}
}
function recomCallback(xmlHttp){
	var re = xmlHttp.responseText;
	
	if(re=="0"){
		showError($('statusBar'), "查询异常");	
		return;
	}else{
		var obj = eval("(" +re+ ")");
		if(obj[0].nutrisurveyid!=null && obj[0].nutrisurveyid>0){
			$('nutriSuifang.zhushia').value= obj[0].zhushia;
			$('nutriSuifang.zhushib').value= obj[0].zhushib;
			$('nutriSuifang.zhushic').value= obj[0].zhushic;
			$('nutriSuifang.zhushitotal').value= obj[0].zhushitotal;
			
			$('nutriSuifang.shucaia').value= obj[0].shucaia;
			$('nutriSuifang.shucaib').value= obj[0].shucaib;
			$('nutriSuifang.shucaic').value= obj[0].shucaic;
			$('nutriSuifang.shucaitotal').value= obj[0].shucaitotal;
			
			$('nutriSuifang.yuroua').value= obj[0].yuroua;
			$('nutriSuifang.yuroub').value= obj[0].yuroub;
			$('nutriSuifang.yurouc').value= obj[0].yurouc;
			$('nutriSuifang.yuroutotal').value= obj[0].yuroutotal;
			
			$('nutriSuifang.doua').value= obj[0].doua;
			$('nutriSuifang.doub').value= obj[0].doub;
			$('nutriSuifang.douc').value= obj[0].douc;
			$('nutriSuifang.doutotal').value= obj[0].doutotal;
			
			$('nutriSuifang.rua').value= obj[0].rua;
			$('nutriSuifang.rub').value= obj[0].rub;
			$('nutriSuifang.ruc').value= obj[0].ruc;
			$('nutriSuifang.rutotal').value= obj[0].rutotal;
			
			$('nutriSuifang.shuiguoa').value= obj[0].shuiguoa;
			$('nutriSuifang.shuiguob').value= obj[0].shuiguob;
			$('nutriSuifang.shuiguoc').value= obj[0].shuiguoc;
			$('nutriSuifang.shuiguototal').value= obj[0].shuiguototal;
			
			$('nutriSuifang.youzhia').value= obj[0].youzhia;
			$('nutriSuifang.youzhib').value= obj[0].youzhib;
			$('nutriSuifang.youzhic').value= obj[0].youzhic;
			$('nutriSuifang.youzhitotal').value= obj[0].youzhitotal;
		}
	}
}
function setEmpty(){
	$('nutriSuifang.zhushia').value= "";
	$('nutriSuifang.zhushib').value= "";
	$('nutriSuifang.zhushic').value= "";
	$('nutriSuifang.zhushitotal').value= "";
	
	$('nutriSuifang.shucaia').value= "";
	$('nutriSuifang.shucaib').value= "";
	$('nutriSuifang.shucaic').value= "";
	$('nutriSuifang.shucaitotal').value= "";
	
	$('nutriSuifang.yuroua').value= "";
	$('nutriSuifang.yuroub').value= "";
	$('nutriSuifang.yurouc').value= "";
	$('nutriSuifang.yuroutotal').value= "";
	
	$('nutriSuifang.doua').value= "";
	$('nutriSuifang.doub').value= "";
	$('nutriSuifang.douc').value= "";
	$('nutriSuifang.doutotal').value= "";
	
	$('nutriSuifang.rua').value= "";
	$('nutriSuifang.rub').value= "";
	$('nutriSuifang.ruc').value= "";
	$('nutriSuifang.rutotal').value= "";
	
	$('nutriSuifang.shuiguoa').value= "";
	$('nutriSuifang.shuiguob').value= "";
	$('nutriSuifang.shuiguoc').value= "";
	$('nutriSuifang.shuiguototal').value= "";
	
	$('nutriSuifang.youzhia').value= "";
	$('nutriSuifang.youzhib').value= "";
	$('nutriSuifang.youzhic').value= "";
	$('nutriSuifang.youzhitotal').value= "";
}
/*
function zhushi(){
	var a = $('nutriSuifang.zhushia').value;
	var b = $('nutriSuifang.zhushib').value;
	var c = $('nutriSuifang.zhushic').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.zhushitotal').value =  total.toFixed(1);
}
function shucai(){
	var a = $('nutriSuifang.shucaia').value;
	var b = $('nutriSuifang.shucaib').value;
	var c = $('nutriSuifang.shucaic').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.shucaitotal').value =  total.toFixed(1);
}
function yurou(){
	var a = $('nutriSuifang.yuroua').value;
	var b = $('nutriSuifang.yuroub').value;
	var c = $('nutriSuifang.yurouc').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.yuroutotal').value =  total.toFixed(1);
}
function dou(){
	var a = $('nutriSuifang.doua').value;
	var b = $('nutriSuifang.doub').value;
	var c = $('nutriSuifang.douc').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.doutotal').value =  total.toFixed(1);
}
function ru(){
	var a = $('nutriSuifang.rua').value;
	var b = $('nutriSuifang.rub').value;
	var c = $('nutriSuifang.ruc').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.rutotal').value =  total.toFixed(1);
}
function shuiguo(){
	var a = $('nutriSuifang.shuiguoa').value;
	var b = $('nutriSuifang.shuiguob').value;
	var c = $('nutriSuifang.shuiguoc').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.shuiguototal').value =  total.toFixed(1);
}
function youzhi(){
	var a = $('nutriSuifang.youzhia').value;
	var b = $('nutriSuifang.youzhib').value;
	var c = $('nutriSuifang.youzhic').value;
	var total = 0.0;
	if(a==null || a==''){
		a=0.0;
	}
	if(b==null|| b==''){
		b=0.0;
	}
	if(c==null || c==''){
		c=0.0;
	}
	total = parseFloat(a)+ parseFloat(b) + parseFloat(c);
	$('nutriSuifang.youzhitotal').value =  total.toFixed(1);
}
*/
</script>